<?php

namespace app\admin\model;

use think\Model;

class Rolemodel extends Commonmodel {

    public function __construct(array $data = [])
    {
        $this->table = 'zhjs_role';
        $this->pk = 'id';
        parent::__construct($data);
    }

    /**
     * 保存
     * @param $data
     * @param null $id
     * @return bool|string
     */
    public function saveInfo($data, $id = null){

        if(!$data)  return false;

        if(!$id)  $data['create_date'] = date("Y-m-d H:i:s", time());

        $res = parent::saveDataInfo($data, $id);

        if(!$res)  return false;
        return $res;
    }

    /**
     * 删除栏目
     * @param $id
     * @return bool|string
     */
    public function delRole($id){
        if(!$id)  return false;

        $res = parent::saveDataInfo(['is_delete'=>2], $id);

        if(!$res)  return false;
        return $res;
    }
}

?>